<form action="{:request()->url()}" autocomplete="off" class="layui-form layui-card" data-auto="true" method="post">
    <div class="layui-card-body padding-left-40">

        <div class="layui-form-item relative block">
            <span class="color-green font-w7">商品编号</span>
            <span class="color-desc margin-left-5">Goods Code</span>
            <div class="layui-input layui-bg-gray">{$vo.code|default=''}</div>
        </div>

        <div class="layui-form-item relative block">
            <span class="color-green font-w7">商品名称</span>
            <span class="color-desc margin-left-5">Goods Name</span>
            <div class="layui-input layui-bg-gray">{$vo.name|default=''}</div>
        </div>

        <div class="layui-form-item">
            <div class="relative block">
                <span class="color-green font-w7">库存数据</span>
                <span class="color-desc margin-left-5">Goods Stock Data</span>
                <table class="layui-table border-0 margin-0" lay-skin="nob">
                    <colgroup>
                        <col style="width:auto">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:99px">
                        <col style="width:18px">
                    </colgroup>
                    <thead>
                    <tr class="layui-bg-cyan notselect">
                        <th class="text-left nowrap">商品规格</th>
                        <th class="text-center nowrap">市场价格</th>
                        <th class="text-center nowrap">销售价格</th>
                        <th class="text-center nowrap">库存统计</th>
                        <th class="text-center nowrap">总销统计</th>
                        <th class="text-center nowrap">库存剩余</th>
                        <th class="text-center nowrap pointer" data-batchset data-tips-text="批量设置库存">
                            <i class="layui-icon font-s10" style="color:#FFF">&#xe63c;</i> 入库数量
                        </th>
                        <th class="padding-0"></th>
                    </tr>
                    </thead>
                </table>
                <div style="max-height:500px;overflow-y:scroll">
                    <table class="layui-table margin-0" lay-skin="nob">
                        <colgroup>
                            <col style="width:auto">
                            <col style="width:80px">
                            <col style="width:80px">
                            <col style="width:80px">
                            <col style="width:80px">
                            <col style="width:80px">
                            <col style="width:99px">
                        </colgroup>
                        <tbody>
                        {foreach $vo.items as $goods}
                        <tr>
                            <td class="layui-bg-gray layui-elip">{$goods.goods_spec|show_goods_spec}</td>
                            <td class="layui-bg-gray text-center">￥{$goods.price_market+0}</td>
                            <td class="layui-bg-gray text-center">￥{$goods.price_selling+0}</td>
                            <td class="layui-bg-gray text-center">{$goods.stock_total|default=0}</td>
                            <td class="layui-bg-gray text-center">{$goods.stock_sales|default=0}</td>
                            <td class="layui-bg-gray text-center">{$goods.stock_total-$goods.stock_sales}</td>
                            <td class="padding-0 nowrap">
                                <input name="goods_code[]" type="hidden" value="{$goods.goods_code|default=''}">
                                <input name="goods_spec[]" type="hidden" value="{$goods.goods_spec|default=''}">
                                <label>
                                    <input class="layui-input text-right border-0 padding-right-40" data-blur-number="0" maxlength="20" name="goods_stock[]" value="0">
                                    <span class="input-right-icon layui-bg-gray">件</span>
                                </label>
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>确定入库</button>
        <button class="layui-btn layui-btn-danger" data-close data-confirm="确定要取消入库吗？" type='button'>取消入库</button>
    </div>
</form>

<script>
    $('[data-batchset]').on('click', function () {
        layer.prompt({
            title: '请输入库存数量【 取值范围：1 - 999999 】', formType: 0, value: 1, success: function ($fn) {
                $fn.find('.layui-layer-input').attr({'data-value-min': 1, 'data-value-max': 999999, 'data-blur-number': 0});
            }
        }, function (value, index) {
            layer.close(index), $('[name^="goods_stock"]').val(parseInt(value) || 0);
        });
    });
</script>
